package com.itshi.plic;

import com.itshi.pojo.Account;
import com.mysql.jdbc.Driver;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;

/**
 * @author げっしょく
 * @date 2021/8/20
 */
public class Test3 {
    public static void main(String[] args) throws Exception{
        Class.forName("com.mysql.jdbc.Driver");
        Connection con = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/song", "root", "1234");
        String sql = "select * from account";
        Statement sta = con.createStatement();
        ArrayList<Account> list = new ArrayList<>();
        ResultSet result = sta.executeQuery(sql);
        while(result.next()){
            int anInt = result.getInt(1);
            String string = result.getString(2);
            int anInt1 = result.getInt(3);
            list.add(new Account(anInt,string,anInt1));
        }
        System.out.println(list);
        con.close();
        sta.close();
        result.close();
    }
}
